import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

/**
 * @author CoderXshuai
 * @date 2021/8/5 21:22
 */
public class ListGrades {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(reader.readLine());
        String temp;
        String[] arr;
        StringBuilder builder;
        Map<Integer, String> map = new HashMap<>((int) Math.ceil(n / 0.75));
        for (int i = 0; i < n; i++) {
            temp = reader.readLine();
            arr = temp.split(" ");
            builder = new StringBuilder();
            map.put(Integer.parseInt(arr[2]), builder.append(arr[0]).append(" ").append(arr[1]).toString());
        }
        temp = reader.readLine();
        arr = temp.split(" ");
        int start = Integer.parseInt(arr[0]);
        int end = Integer.parseInt(arr[1]);
        Object[] keys = map.keySet().stream().filter(integer -> integer >= start && integer <= end).sorted().toArray();
        for (int i = keys.length - 1; i >= 0; i--) {
            System.out.println(map.get((int) keys[i]));
        }
        if (keys.length < 1)
            System.out.println("NONE");
        reader.close();
    }
}
